package cn.edu.sjtu.flaw_detection.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.StandardCharsets;

/**
 * @author loumoon
 * @date 2019-12-01 19:16
 */
@Configuration
public class BeanConfig {

  @Bean
  public RestTemplate restTemplate() {
    RestTemplate restTemplate = new RestTemplate();

    restTemplate
        .getMessageConverters()
        .removeIf(converter -> converter instanceof StringHttpMessageConverter);
    restTemplate.getMessageConverters().add(new StringHttpMessageConverter(StandardCharsets.UTF_8));
    return restTemplate;
  }
}
